/*******************************************************************
 *   > File Name: led.c
 *   > Author: fly
 *   > Mail: 1358326274@qq.com
 *   > Create Time: 2019年10月30日 星期三 18时21分05秒
 ******************************************************************/
#include "common.h"

#define GPJ0CON     0xE0200240
#define GPJ0DAT     0xE0200244
#define GPD0CON     0xE02000A0
#define GPD0DAT     0xE02000A4

#define rGPJ0CON    (*(volatile unsigned int *)GPJ0CON)
#define rGPJ0DAT    (*(volatile unsigned int *)GPJ0DAT)
#define rGPD0CON    (*(volatile unsigned int *)GPD0CON)
#define rGPD0DAT    (*(volatile unsigned int *)GPD0DAT)

void delay(void)
{
    volatile unsigned int i = 900000;
    while(i--);
}

void led_init(void)
{
    rGPJ0CON |= 0x11111111;
    rGPD0CON |= 0x00000010;

    led_1_off();
    led_2_off();
    led_3_off();
    led_4_off();
}

void led_1_on(void)
{
    rGPJ0DAT &= ~(0x1<<3);//置0，输出低电平
}
void led_1_off(void)
{
    rGPJ0DAT |= (0x1<<3);//置1，输出高电平
}

void led_2_on(void)
{
    rGPJ0DAT &= ~(0x1<<4);//置0，输出低电平
}
void led_2_off(void)
{
    rGPJ0DAT |= (0x1<<4);//置1，输出高电平
}

void led_3_on(void)
{
    rGPJ0DAT &= ~(0x1<<5);//置0，输出低电平
}
void led_3_off(void)
{
    rGPJ0DAT |= (0x1<<5);//置1，输出高电平
}

void led_4_on(void)
{
	rGPD0DAT &= ~(1<<1);
}
void led_4_off(void)
{
	rGPD0DAT |= (1<<1);
}
